import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_plugin_bugly2/flutter_plugin_bugly2.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              RaisedButton(onPressed: () {
                if (Platform.isAndroid) {
                  FlutterPluginBugly2.setUp('8859df4f98');
                }
              },
                child: Text('初始化bugly'),),
              RaisedButton(onPressed: ()=> Future.delayed(Duration(seconds: 1))
                  .then((value) => throw Exception("测试上报异常"))
                  .catchError((error, stack)=>FlutterPluginBugly2.postException(error,stack)),
                child: Text('上报异常'),),
            ],
          ),
        ),
      ),
    );
  }
}
